<script setup>
  import { onLoad } from '@dcloudio/uni-app'
  import {ref} from 'vue'
import {postTakeDeliveryApi} from '@/apis/task'

let taskId = ref('')

const formData = {
  id:taskId.value,
  cargoPickUpPictureList:[
    {url:'https://img0.baidu.com/it/u=2981353902,171884611&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'}
  ],
  cargoPictureList:[
    {url:'https://piccn.ihuaben.com/pic/chapter/202001/2700/1580057061338-jl19a7l4uf_700-700.jpeg?x-oss-process=image/resize,w_640'}
  ]
}

onLoad((e) => {
  taskId.value = e.id
  formData.id = taskId.value
})

// 提交图片数据
const submitForm = async() => {
  console.log(formData);
 const res = await postTakeDeliveryApi(formData)
 console.log(res);
 if (res.code === 200) {
  uni.reLaunch({ url: '/pages/task/index' })
 }
}
</script>
<template>
  <view class="page-container">
    <view class="receipt-info">
      <uni-file-picker limit="3" title="请拍照上传回单凭证"></uni-file-picker>
      <uni-file-picker limit="3" title="请拍照上传货品照片"></uni-file-picker>
    </view>
    <button @click="submitForm" class="button">提交</button>
  </view>
</template>

<style lang="scss" scoped>
  .page-container {
    padding: 30rpx;
  }

  .receipt-info {
    min-height: 600rpx;
    background-color: #fff;
    padding: 20rpx 30rpx;
    border-radius: 16rpx;

    ::v-deep .uni-file-picker {
      margin-bottom: 30rpx;
    }
  }

  .button {
    height: 100rpx;
    text-align: center;
    line-height: 100rpx;
    /* #ifdef APP */
    padding-top: 4rpx;
    /* #endif */
    border-radius: 100rpx;
    margin-top: 60rpx;
    color: #fff;
    font-size: $uni-font-size-big;
    background-color: $uni-primary;

    &[disabled],
    &.disabled {
      color: #fff;
      background-color: #fadcd9;
    }
  }
</style>
